from collections import defaultdict
from typing import List


class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        ans=[]
        has=defaultdict(list)
        for c in strs:
            # 哈希表分组
            has[str(sorted(c))].append(c)
        for k,v in has.items():
            ans.append(v)
        return ans